package com.zzy.module.todo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzy.common.entity.db.TodoDaoEntity;
import com.zzy.module.todo.entity.QqList;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * @author zhuZhaoYang
 * @date 2021/12/5 14:19
 */
@Mapper
public interface TodoMapper extends BaseMapper<TodoDaoEntity> {

    /**
     * 获取有todo的qq列表
     *
     * @return qq列表
     */
    @Select("select distinct qq.id,qq.number from qq,todo where qq.id = todo.qq_id")
    IPage<QqList> getQqList(Page<QqList> page);

    /**
     * 根据qqid获取已完成待办
     *
     * @param id id
     * @return 已完成待办
     */
    @Select("select * from todo,qq where qq.id=todo.qq_id and qq_id=#{id} and todo.state=1 ")
    IPage<TodoDaoEntity> getFinishedTodoByQqId(Integer id, Page<TodoDaoEntity> page);

    /**
     * 根据qqid获取未完成待办
     *
     * @param id id
     * @return 已完成待办
     */
    @Select("select * from todo,qq where qq.id=todo.qq_id and qq_id=#{id} and todo.state=0 ")
    IPage<TodoDaoEntity> getTodo(Integer id, Page<TodoDaoEntity> page);
}
